package Servler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class Servle extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("name");
        String age = req.getParameter("age");
        String chengji = req.getParameter("chengji");
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("C:\\Users\\Admin\\Desktop\\2.txt",true));
        bufferedWriter.write("姓名:"+name+"年龄:"+age+"成绩:"+chengji);
        bufferedWriter.newLine();
        bufferedWriter.flush();
        bufferedWriter.close();

        PrintWriter writer = resp.getWriter();
        writer.print("tijiao");
        writer.close();
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
